@(prod: Product, comments: List[Comment], orderItemForm: Form[OrderItem], commentForm: Form[Comment])

@import helper._
@import controllers.user.UserController


@main(prod.getName()) {
	<div style="width:500px; margin:0 auto; padding: 7px; border: solid 2px; border-radius: 7px;">
		<h5 style="float:left;">@prod.getName()
		 @if(session.get("currentUserEmail") != null && UserController.getCurrentUser().getPriv("worker")){
		 		<h5 style="text-align:right"><a href="/product/delete/@prod.getId()"><font color="red">x</font></a></h5>
		 }else{
				<h5 style="text-align:right"><font color="grey">x</font></h5>
		 }
		</h5>

		<img class="img-responsive" src="@routes.Assets.at("images/product/")@prod.getPhoto()"/>
		
		<hr />
		<p>Price: @prod.getPrice() HUF </p><br />
		<p>Description: @prod.getDescription()</p>
		<a href="javascript:history.go(-1)"><-back</a>

		@form(controllers.product.routes.ProductController.addToCart(prod.getId())) {
			<p align="right">
 				@inputText(orderItemForm("amount"), '_value -> 1) 
				<input class="btn btn-success btn-sm" type="submit" value="Add to Cart" >
			</p>
		}
	
	<div class="panel panel-success">
		<div class="panel-heading"><h5>Comments</h5></div>
			<div class="panel-body">
			@form(controllers.product.routes.ProductController.addComment(prod.getId())){
				@helper.input(field = commentForm("text"), '_label -> "") { (id, name, value, args) =>
					   <div>
        			<textarea name="@name" id="@id" rows='5' placeholder="Type comment ..." style="width:100%;">@value</textarea>
				     </div>
				}
				
				<input class="btn btn-success btn-sm" type="submit" value="Comment" @if(session.get("currentUserEmail") == null){disabled="disabled"}>
			}	

				@if(comments != null){
					@for(comment <- comments){
						<div class="row">
							
							<h5 class="col-md-6">
								<strong>@comment.getUser().getEmail()</strong>
							</h5>
							<h5 class="col-md-6 text-right">
								<strong>@comment.getDate().toLocaleString()</strong>
							</h5>
						</div>
						<div>
							@comment.getText()
						</div>
						<hr />
						<br />
						
				}
				}else{
					<p> There are no comments yet!
				}
			</div>
	</div>
	</div>
	
}